package cn.shyouchi.wuguanjia.android.api.train;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.shyouchi.wuguanjia.android.api.ClientProvider;
import cn.shyouchi.wuguanjia.android.api.UserStorageProvider;
import cn.shyouchi.wuguanjia.android.components.storage.UserStorage;
import cn.shyouchi.wuguanjia.android.model.BaseRequestResult;
import cn.shyouchi.wuguanjia.android.ui.train.MasterEntity;
import cn.shyouchi.wuguanjia.android.ui.train.TrainEntity;
import cn.shyouchi.wuguanjia.android.ui.train.TrainPostEntity;
import cn.shyouchi.wuguanjia.android.ui.trainstatistic.TrainStatistEntity;
import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by Eenie on 2017/3/22 at 16:33
 * Email: 472279981@qq.com
 * Des:
 */

public class TrainApi {


    private TrainService mService;

    private UserStorage mUserStorage;


    public TrainApi() {
        mUserStorage = UserStorageProvider.Default();
        Retrofit retrofit = ClientProvider.getDefaultClient().getRetrofit(mUserStorage);
        mService = retrofit.create(TrainService.class);
    }

    public Observable<BaseRequestResult<List<TrainEntity>>> getTrainData() {
        return mService.getTrainData();
    }

    public Observable<BaseRequestResult<MasterEntity>> getMasterData(int page) {
        Map<String, Object> params = new HashMap<>();
        params.put("type", 1);
        params.put("page", page);
        return mService.getMasterData(params);
    }


    public Observable<BaseRequestResult<List<TrainStatistEntity>>> getTrainStatistic(String projectid) {
        Map<String, Object> params = new HashMap<>();
        params.put("projectid", projectid);
        return mService.getTrainStatistic(params);
    }

    public Observable<BaseRequestResult<TrainPostEntity>> getPostData(int page) {
        Map<String, Object> params = new HashMap<>();
        params.put("type", 2);
        params.put("page", page);
        return mService.getPostData(params);
    }


    public Observable<BaseRequestResult<String>> addTrainRecorder(int id, int type, int page) {
        Map<String, Object> params = new HashMap<>();
        params.put("type", type);
        params.put("page", page);
        params.put("training_id", id);
        return mService.addTrainRecorder(params);
    }




}
